package org.netbeans.modules.qcubedpalette.qtextbox;

/**
 * QTextMode
 * Java representation of the QTextMode QCodo PHP class.
 */
public enum QTextMode {
	SINGLELINE("SingleLine"),
	MULTILINE("MultiLine"),
	PASSWORD("Password");

	private final String name;

	QTextMode(String name) {
		this.name = name;
	}

	public String GetQCodoString() {
		return this.name;
	}

	/**
	 * Allows you to access the enum as if it were an array.  Will return the
	 * first/last element if the specified index is less/greater than the number
	 * of elements in the enum.
	 * @param index the index to refer to
	 * @return the QTextMode at the specified index
	 */
	public static QTextMode GetFromIndex(int index) {
		switch (index) {
			case 0:
				return QTextMode.SINGLELINE;
			case 1:
				return QTextMode.MULTILINE;
			case 2:
				return QTextMode.PASSWORD;
			default:
				if (index < 0) {
					return QTextMode.SINGLELINE;
				} else {
					return QTextMode.PASSWORD;
				}
		}
	}
}
